﻿using System.ComponentModel;
using System.Windows.Controls;
using MyFloridaHouse.libSvOpenDistricts.Districts;
using System.IO;

namespace MyFloridaHouse.libSvOpenDistricts.Dialogs
{
    public partial class PlanInfoDlg : _BaseDlg
    {

        private PlanInfoDlgView dlgWindow = new PlanInfoDlgView();

        public PlanInfoDlg(PropertyChangedEventHandler propertyChangedEventHandler, StackPanel childWindowStackPanel, DistrictPlanTypes iDistrictPlanTypes)
        {
            districtPlanTypes = iDistrictPlanTypes;
            InitializeDlgWindow(propertyChangedEventHandler, childWindowStackPanel, dlgWindow);
            districtPlanTypes.PropertyChanged += OnDistrictPlanTypesPropertyChanged;

        }

        // The xaml Dlg depends on properties down in districtPlanTypes, so we need to let it know when districtPlanTypes properties change
        private void OnDistrictPlanTypesPropertyChanged(object sender, PropertyChangedEventArgs args)
        {
            NotifyPropertyChanged(args.PropertyName);
        }


        #region form data properties

        private DistrictPlanTypes _districtPlanTypes;
        public DistrictPlanTypes districtPlanTypes
        {
            get { return _districtPlanTypes; }
            set
            {
                if (_districtPlanTypes != value)
                {
                    _districtPlanTypes = value;
                    NotifyPropertyChanged("districtPlanTypes");
                }
            }
        }

        private string _planName;
        public string planName
        {
            get { return _planName; }
            set
            {
                if (_planName != value)
                {
                    _planName = value;
                    NotifyPropertyChanged("planName");
                }
            }
        }

        private string _planDescription;
        public string planDescription
        {
            get { return _planDescription; }
            set
            {
                if (_planDescription != value)
                {
                    _planDescription = value;
                    NotifyPropertyChanged("planDescription");
                }
            }
        }

        // helper property so accessors don't have to access districtPlanTypes through PlanInfoDlg
        public int planDistrictCount
        {
            get
            {
                return districtPlanTypes.districtPlanTypeDistrictCount;
            }
        }

        // helper property so accessors don't have to access districtPlanTypes through PlanInfoDlg
        public string planTypeID
        {
            get 
            { 
                int selectedIndex = districtPlanTypes.districtPlanTypeSelectedIndex;
                return districtPlanTypes.districtPlanTypeList[selectedIndex].districtPlanTypeID;; 
            }
        }

        // helper property so accessors don't have to access districtPlanTypes through PlanInfoDlg
        public string planTypeName
        {
            get 
            { 
                int selectedIndex = districtPlanTypes.districtPlanTypeSelectedIndex;
                return districtPlanTypes.districtPlanTypeList[selectedIndex].displayName;; 
            }
        }


        #endregion




    }
}
